/*
 * Copyright 2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.dailydev.wave.robot.serializer;

import org.dailydev.wave.robot.RobotException;

import com.google.wave.api.impl.RobotMessageBundleImpl;

/**
 * Generic interface for serializer/deserializer between String (eg. JSON or
 * XML) and specific object representation (eg. {@link RobotMessageBundleImpl}).
 * 
 * @author Roman Bosak, DailyDev.org
 */
public interface ISerializer<T> {

    /**
     * Deserializes {@link String} (eg. JSON or XML) into arbitrary object
     * specified (eg. {@link RobotMessageBundleImpl}).
     * 
     * @param toDeserialize
     *            string to be deserialized to an object
     * @return An object representing deserialized string.
     * @throws RobotException
     *             If any problem during deserialization occurs.
     */
    T deserialize(String toDeserialize) throws RobotException;

    /**
     * Serializes object from <code>toSerialize</code> parameter to its
     * {@link String} representation.
     * 
     * @param toSerialize
     *            reference to object to be serialized
     * @throws RobotException
     *             If any problem during serialization occurs.
     */
    String serialize(T toSerialize) throws RobotException;
}
